package com.fengye.algorithms.leecode;

/**
 * @Author fengye
 * @Date 2023/4/8 11:42
 **/
public class HammingWeight191 {
    public int hammingWeight(int n) {
        String nStr = Integer.toBinaryString(n);
        int num = 0;
        for(int i=0;i<nStr.length();i++) {
            if(nStr.charAt(i) == '1') {
                num++;
            }
        }
        return num;
    }
}
